import { _decorator, Component, Node, UITransform } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('pierController')
export class pierController extends Component {
    //是否为开始柱子
    IsStart:boolean = false
    start() 
    {
        if(!this.IsStart)
        {
            this.randomWidth();
        }
        this.delete();
    }
    randomWidth()
    {
        let scaleX = Math.random() * 3 + 1
        const ui:UITransform = this.node.getComponent(UITransform)
        const height = ui.contentSize.height;
        const width = Math.random() * 200 + 50
        ui.setContentSize(width,height)
    }
    delete()
    {
        this.node.parent.parent.on('moveOk',()=>
        {
            const x = this.node.getPosition().x
            const width = this.node.getComponent(UITransform).contentSize.width
            if(x + width < -640)
            {
                this.node.destroy();
            }
        },this)
    }
    update(deltaTime: number) 
    {
        
    }
}


